<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Lista Componentes</title>
        <script type="text/javascript" src="../js/jquery.js" ></script>
        <script type="text/javascript" src="../js/jquery.validate.js"></script>
        <script type="text/javascript" src="../js/jquery.tablescroll.js"></script>
        <script type="text/javascript" src="../js/forms.js"></script>
        <script type="text/javascript" src="../js/jquery-ui-1.8.2.custom.min.js" ></script>
        <link rel="stylesheet" href="../css/ui-lightness/jquery-ui-1.8.2.custom.css">
    <link rel="stylesheet" href="../css/forms.css"></head>

    <script>
        $(document).ready(function(){
            $("#fm_delete").validate({
                rules: {
                    id_componente: {required: true,digits: true}
                },
                submitHandler: function(form) {
                    salvar(form);
                }
            });
        });
        function del(id){
            $("#msg").dialog({
                buttons: {
                    Ok: function() {
                        $(this).dialog('close');
                        $("#form").submit();
                    }
                }
            });
            $("#id_componente").val(id.value);
            $("#fm_delete").submit();
        }

       

    </script>
    <body>
        <div id="formulario">
            <h1>Componentes</h1>
            <form id="fm_delete"  method="post" action="delete.jsp">
                <input type="hidden" id="id_componente" name="id_componente" value="">
            <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
            <form name="form" id="form" method="post" >
                <p>
                    <label class="lbInput">Descrição</label>
                    <input name="desc" value="${param.desc}">
                </p>
                <input type="image" class="noborder" src="../imagens/procurar.png" onclick="submit()">
            <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
            <br>
          
                <sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
                    SELECT  Componentes.*
                    FROM Componentes
                    where desc_componente like ?
                    <sql:param value="${param.desc}%"/>
                    order by desc_componente
                </sql:query>
                <table cellspacing="0" width="90%">  <thead>
                        <th>Código</th>
                        <th>Componente</th>
                        <th>Carga Horária</th>
                        <!--th width="18%"></th-->
                    </thead>
                    <tfoot>
                        <tr>
                            <td colspan="4">
                                ${query.rowCount} registros encontrados
                            </td>
                        </tr>
                    </tfoot>
                    <c:forEach var="row" items="${query.rows}">
                        <tr>
                            <td>${row.codigo_componente}</td>
                            <td>${row.desc_componente}</td>
                            <td>${row.carga_componente}</td>
                            <!--td><form method="post" action="fm_update_Componentes.jsp">
                                    <input type="hidden" name="chave" value="${row.id_componente}">
                                    <input type="image" class="noborder" src="../imagens/editar.png" onclick="submit()">
                                <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
                            </td-->
                        </tr></c:forEach>
                    </table>
                   
                    <div id="msg" style="display:none"></div>
                </div>
        
    </body>
</html>
